package com.api.shopapi.service.impl;

import com.api.shopapi.entity.DeviceYjgateway;
import com.api.shopapi.entity.dto.DeviceYjgatewayDTO;
import com.api.shopapi.mapper.DeviceYjgatewayMapper;
import com.api.shopapi.service.DeviceYjgatewayService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("DeviceYjgatewayServiceImplOne")
public class DeviceYjgatewayServiceImpl implements DeviceYjgatewayService {

    @Autowired
    private DeviceYjgatewayMapper deviceYjgatewayMapper;

    @Override
    public int insert(DeviceYjgateway deviceYjgateway) {
        return deviceYjgatewayMapper.insert(deviceYjgateway);
    }

    @Override
    public int update(DeviceYjgateway deviceYjgateway) {
        return deviceYjgatewayMapper.update(deviceYjgateway);
    }


    @Override
    public DeviceYjgateway getByGatewayId(String gatewayId) {
        return deviceYjgatewayMapper.getByGatewayId(gatewayId);
    }

    @Override
    public DeviceYjgateway getByUserCode(String userCode) {
        return deviceYjgatewayMapper.getByUserCode(userCode);
    }

    @Override
    public PageInfo<DeviceYjgatewayDTO> getPage(int pageIndex, int pageSize, String phone, String gatewayId) {
        PageHelper.startPage(pageIndex,pageSize);
        List<DeviceYjgatewayDTO> deviceYjgatewayDTOList = deviceYjgatewayMapper.getPage(phone, gatewayId);
        return new PageInfo<>(deviceYjgatewayDTOList);
    }
}
